package com.theeviljames.coursework.receiver;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class UserInputTask extends Thread {
	
	private Receiver receiver;
	
	public UserInputTask(Receiver receiver) {
		this.receiver = receiver;
	}
	
	@Override
	public void run() {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			while(true){
				String input = in.readLine();
				if(input.equals("START")){
					receiver.setTransmit(true);
				}
				else if(input.equals("STOP")){
					receiver.setTransmit(false);
				}
				Thread.yield();
			}	
		} catch (Exception e) {
			// TODO: handle exception
		}
		
	}
}
